package com.hc.com.testCalibration;


import com.hc.activity.MainActivity;
import com.hc.commonData.SysCommonData;
import com.hc.util.OrderUtil;

import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
/**
 * 
 * 
 * @author tiansl
 *
 */
public class TestCalibrationService {

	/**
	 * 
	 * 开始校准
	 * @param content
	 */
	public static void starTestCorrect(Context context){
		
		
		OrderUtil.ECCONTROLTEST_order("3");//下发开始校准命名
		
		
		int i = 0;
		while ( i < 5 ) 
		{
			
			String result = OrderUtil.getEcMcuRealStatus();
		  if (result!=null&& result.equals("5") ) 
		  {
			  
			  SysCommonData.calibratioStats = 1;//将校准模式设置为0
			  	Toast.makeText(context.getApplicationContext(), "提示：测试人员必须在原地旋转1圈以上", 1).show();
				Intent intent = new Intent(context,TestCalibrationActivity.class);
				context.startActivity(intent);//跳转界面
			return ;
			
		  }
		  try {
				Thread.sleep(20);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		  i++;
		}
		
		
		
	
		Toast.makeText(context.getApplicationContext(), "提示：开启校准模式失败", 1).show();
		
	
	}
	
	/**
	 * 
	 * 结束校准
	 * @param content
	 */
	public static void closeTestCorrect(Context context){
		
		
		OrderUtil.ECCONTROLTEST_order("4");//下发开始校准命名
		
		
		int i = 0;
		while ( i < 5 ) 
		{
			
			String result = OrderUtil.getEcMcuRealStatus();
		  if (result!=null&& result.equals("0") ) 
		  {
			  	Toast.makeText(context.getApplicationContext(), "提示：结束校准模式成功", 1).show();
				Intent intent = new Intent(context,MainActivity.class);
				context.startActivity(intent);//跳转界面
				return ;
			
		  }
			  try {
				Thread.sleep(20);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		  i++;
		}
		
		Toast.makeText(context.getApplicationContext(), "提示：结束校准模式失败", 1).show();
	}
	
}
